package vn.demand.dragon.model.business
{
	import mx.rpc.AsyncToken;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;

	public class LoadSuppliersDelegate 
	{
		private var service : HTTPService;

		public function LoadSuppliersDelegate( result:Function, fault:Function ) 
		{
			// constructor will store a reference to the service we're going to call
			this.service = new HTTPService();
			this.service.url = "http://dev.dragon.com/index.php?m=suppliers&a=suppliers_xml&suppressHeaders=1";
//			this.service.url = "data/quote_search.xml";
			this.service.method = 'POST';
			this.service.resultFormat = 'e4x';
			
			this.service.addEventListener(ResultEvent.RESULT, result);
			this.service.addEventListener(FaultEvent.FAULT, fault);
		}

		public function searchSupplierService(params:Object = null) : void 
		{
			if (params == null) {
				params = {};
			}
			// call the service
			var token:AsyncToken = service.send(params);
			
			// notify this responder when the service call completes
			token.action = 'searchSupplier';
		}
	}
}